﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.SqlClient;
using System.Data;

namespace projectManagementWeb.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
           

            ViewBag.Message = "Bienvenido a Project Management Web!";

            //this.DBTest(); //todo erase

            return View();
        }

        public ActionResult About()
        {
            return View();
        }
        /*
        private void DBTest() //todo erase! it was just for testing the local DB (returns the current date)
        {
            SqlConnection connectMainDB = new SqlConnection();
            System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/projectManagementWeb");
            connectMainDB.ConnectionString = rootWebConfig.ConnectionStrings.ConnectionStrings["MainDB"].ToString();
            SqlCommand cmdGetProjects = new SqlCommand();
            cmdGetProjects.Connection = connectMainDB;

            cmdGetProjects.CommandText = ("SELECT  getutcdate() as date");
            SqlDataAdapter daProj = new SqlDataAdapter();
            daProj.SelectCommand = cmdGetProjects;
            DataSet dsProj = new DataSet();
            try
            {
              connectMainDB.Open();

              daProj.Fill(dsProj, "table");

            connectMainDB.Close();

            DataTable dt = dsProj.Tables["table"];

            ViewBag.Message2 = dt.Rows[0]["date"].ToString();
            }
            catch (Exception ex)
            {
                ViewBag.Message2 = ex.Message;
            }
            
            /*String comments = string.Empty;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comments += dt.Rows[i]["date"].ToString();
                comments += " ";
                comments += dt.Rows[i]["userName"].ToString();
                comments += " : ";
                comments += dt.Rows[i]["comment"].ToString();
                comments += "\n";
            }
            *
        }*/


    }
}
